<template>
	<view>
		<view class="item">

			<u-icon name="order" color="#1573FF" label="审核意见" label-color="#333333"
				:customStyle="{'line-height': '80rpx','display': 'block','padding-left':'20rpx',}"></u-icon>

			<u-line color="#efefef" :customStyle="{'margin-bottom': '10rpx','display': 'block',}"></u-line>

			<view style="margin: 20rpx;">
				<u-textarea v-model="remark" placeholder="请输入审核意见" height="150"></u-textarea>
			</view>

		</view>


		<view class="button-container">
			<button class="btn-item" @click="commit">{{402==btnKey?'确认通过':
			403==btnKey?'确认驳回':
			404==btnKey?'确认拒绝':
			405==btnKey?'确认撤单':''}}</button>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				btnKey: '',
				processOperationType: '',
				remark: '',
				addbean: {}

			}
		},
		methods: {
			commit() {

				let that = this;

				if (uni.$u.test.isEmpty(this.remark)) {
					this.$u.toast('请输入审核意见')
					return
				}

				uni.showModal({
					content: '确定提交吗?',
					success(res) {
						if (res.confirm) {

							if (402 == that.btnKey) {
								that.addbean.approveContent = that.remark

								that.$u.api.applyforAppEdit(that.addbean).then(res => {
									that.$u.toast('操作成功！')
									uni.$emit('refund-finish', true)
									uni.$emit('refreshOrder', true)
									setTimeout(() => {
										uni.navigateBack()
									}, 1000)
								})
							} else {
								that.$u.api.applyforAppOperation({
									approveContent: that.remark,
									processOperationType: that.processOperationType,
									processKey: that.addbean.processKey,
									instanceId: that.addbean.instanceId
								}).then(res => {
									that.$u.toast('操作成功！')
									uni.$emit('refreshOrder', true)
                  // if(405==that.btnKey){
                  //   uni.$emit("callback-finish", true)
                  // }else {
                    uni.$emit('refund-finish', true)
                  // }
									setTimeout(() => {
										uni.navigateBack()
									}, 1000)
								})
							}

						}
					}
				})
			}
		},
		onLoad(op) {
			//退换车审批通过:402 、退换车审批驳回:403 、 退换车审批拒绝:404 、 退换车审批撤回:405

			console.log('收到的refundOrChangeCarModel==>', getApp().globalData.refundOrChangeCarModel);
			console.log('op==========>', op);


			this.btnKey = op.btnKey;

			this.addbean = uni.$u.test.isEmpty(getApp().globalData.refundOrChangeCarModel) ? {} : getApp().globalData
				.refundOrChangeCarModel;

			getApp().globalData.refundOrChangeCarModel = null;


			uni.setNavigationBarTitle({
				title: op.title
			})

			switch (this.btnKey) {
				case '402':
					break
				case '403':
					this.processOperationType = '3';
					break
				case '404':
					this.processOperationType = '2';
					break
				case '405':
					this.processOperationType = '1';
					break
			}

		},

	}
</script>

<style lang="scss" scoped>
	.bottom {
		position: fixed;
		width: 100%;
		height: 100rpx;
		bottom: 0;
		z-index: 999;
		background-color: white;
		display: flex;
		align-items: center;
		justify-content: center;

		text {
			width: 98%;
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 50rpx;
			background-color: $blue15;
			color: white;
			text-align: center;
			font-size: 30rpx;
		}
	}
</style>
